/* eslint-disable no-redeclare */
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
// 一、
GO = {
    fun1: function fun1() {},
};
function fn1(a, b) {
    AO = {
        b: undefined,
        a: function a() {},
    };
    console.log(a); //function a() {}
    console.log(b); //undefined
    var b = 234;
    console.log(b); //234
    a = 123;
    console.log(a); //function a() {}

    function a() {}
    var a;
    b = 234;
    var b = function () {};
    console.log(a); //123
    console.log(b); //function () {};
}
//fn1(1);

// 二、
GO = {
    fn2: function fn2() {},
    a: undefined,
};
a = 100;

function fn2(e) {
    AO = {
        e: function e() {},
        b: undefined,
        c: undefined,
        a: undefined,
    };
    function e() {}
    arguments[0] = 2;
    console.log(e); //2
    if (a) {
        var b = 123;
    }
    var c;
    a = 10;
    var a;
    console.log(b); //undefined
    f = 123;
    console.log(c); //undefined
    console.log(a); //10
}
var a;
// fn2(1);
// console.log(a); // 100
// console.log(f); // 123

// 三、
GO = {
    fn3: function fn3() {},
    global: undefined,
};
global = 100;
function fn3(global) {
    AO = {
        global: 100,
    };
    console.log(global); //100
    global = 200;
    console.log(global); //200
    var global = 300;
}

// fn3(global);
var global;

// 四、
GO = {
    fn4: function fn4() {},
};
function fn4(a) {
    AO = {
        d: undefined,
        c: function c() {},
        b: undefined,
        a: function a() {},
    };
    var d;
    var c;
    b = 10;
    var a;
    console.log(a); //function a() {}
    a = 123;

    function a() {}
    console.log(a); //function a() {}
    var b;
    console.log(b); //10

    function c() {}
    console.log(c); //function c() {}
    console.log(d); //undefined
    d = 100;
    console.log(d); //100
}
// fn4(5);

// 五、
let obj = {
    // GO={
    //   a:undefined,
    //   fn:function fn(){}
    // }
    a: 110,
    fn: function (a) {
        AO = {
            a: 110,
        };
        console.log(a); //110
        a = 10;
        console.log(a); //10
    },
};

// obj.fn(obj.a);

// 六、
// 1,1,2,3,5,8,13,.....
// 求第n项的和, 例子: 求第三项的和, 1 + 1 + 2
function f6(n) {
    if (n == 1) return 1;
    if (n == 2) return 1;
    return f6(n - 1) + f6(n - 2);
}
function f7(n) {
    if (n == 1) return 1;
    return f7(n - 1) + f6(n);
}
console.log(f7(4));
// 七、选做
// 要求输入id 返回数据对象
// 例如: 输入id=111, 返回{id: 111,gname: '海尔冰箱'}
var data = [
    {
        id: 1,
        name: '家电',
        goods: [
            {
                id: 11,
                gname: '冰箱',
                goods: [
                    {
                        id: 111,
                        gname: '海尔冰箱',
                    },
                    {
                        id: 112,
                        gname: '小天鹅冰箱',
                    },
                ],
            },
            {
                id: 12,
                gname: '洗衣机',
            },
        ],
    },
    {
        id: 2,
        name: '服饰',
    },
];